#include "npapi.h"

#include "plugin.h"
#include "npfunctions.h"
#include "scriptable_object.h"
#include "common.h"

NPError NP_LOADDS New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
	TRACE("New");
	return NPERR_NO_ERROR;
}

NPError NP_LOADDS Destroy(NPP instance, NPSavedData** save)
{
	TRACE("Destroy");
	return NPERR_NO_ERROR;
}

NPError NP_LOADDS SetWindow(NPP instance, NPWindow* window)
{
	TRACE("SetWindow");
	return NPERR_NO_ERROR;
}

NPError NP_LOADDS NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
{
	TRACE("NewStream");
	return NPERR_NO_ERROR;
}

NPError NP_LOADDS DestroyStream(NPP instance, NPStream* stream, NPReason reason)
{
	TRACE("DestroyStream");
	return NPERR_NO_ERROR;
}

void NP_LOADDS StreamAsFile(NPP instance, NPStream* stream, const char* fname)
{
	TRACE("StreamAsFile");
}

int32_t NP_LOADDS WriteReady(NPP instance, NPStream* stream)
{
	TRACE("WriteReady");
	return 0;
}

int32_t NP_LOADDS Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
{
	TRACE("Write");
	return -1;
}

void NP_LOADDS Print(NPP instance, NPPrint* platformPrint)
{
	TRACE("Print");
}

int16_t NP_LOADDS HandleEvent(NPP instance, void* event)
{
	TRACE("HandleEvent");
	return -1;
}

void NP_LOADDS URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
	TRACE("URLNotify");
}

NPError NP_LOADDS GetValue(NPP instance, NPPVariable variable, void *value)
{
	TRACE("Entered GetValue");
	NPError res;
	switch(variable)
	{
	case NPPVpluginScriptableNPObject:
		{
			NPObject* obj = CreateScriptableObject(instance);
			*((NPObject**)value) = obj;
			res = NPERR_NO_ERROR;
		}
		break;
	default:
		TRACE("GetValue: unsupported value type %u", (unsigned)variable);
		res = NPERR_INVALID_PARAM;
	}
	TRACE("Exiting GetValue");
	return res;
}

NPError NP_LOADDS SetValue(NPP instance, NPNVariable variable, void *value)
{
	TRACE("SetValue");
	return NPERR_NO_ERROR;
}
